package com.klangner.math.demo;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class SolverDemo {

	private static final String TEMPLATE_FILE = "templates/solution.xhtml";
	private static final String OUTPUT_FILE = "output/test.xhtml";
	private static final String EXPRESSION = "(x+3)^2=5";
	
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
//		SolverDemo ms = new SolverDemo();
//		MathExpressionParser parser = new MathExpressionParser();
//		Mathml	mathml = new Mathml();
//		Node document;
//		
//		document = parser.parse(EXPRESSION);
//		ms.writeToFile(
//			"<h3>Sprowadź do najprostszej postaci wyrażenie</h3>\n" +
//			"<p>\n" + 
//			mathml.serialize(document) + 
//			"</p>\n"
//		);
	}
	
	
	/**
	 * Write content to file
	 * @throws IOException
	 */
	private void writeToFile(String content) throws IOException{
		
		BufferedReader in = new BufferedReader(new FileReader(TEMPLATE_FILE));
		BufferedWriter out = new BufferedWriter(new FileWriter(OUTPUT_FILE));
		
		String line;
	    //Read File Line By Line
	    while ((line = in.readLine()) != null)   {
	    	line = line.replace("$content$", content);
	    	out.write(line + "\n");
	    }
	    
		in.close();
		out.close();  
	}

	
}
